package com.tengfei.mid_term;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvUserName;
    private TextView tvUseClass;
    private TextView tvUserNum;
    private TextView tvUserSex;
    private Button addUser;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getSupportActionBar().setTitle("首页");
        // 初始化界面
        initView();
        // 初始化数据
        initData();
    }

    private void initView() {
        tvUserName = findViewById(R.id.stu_name);
        tvUseClass = findViewById(R.id.stu_class);
        tvUserNum = findViewById(R.id.stu_num);
        tvUserSex = findViewById(R.id.stu_sex);
        addUser = findViewById(R.id.stu_add_user);
    }

    private void initData() {
        tvUserName.setText("欧阳腾飞");
        tvUseClass.setText("A1951");
        tvUserNum.setText("20190203828");
        tvUserSex.setText("男");
        addUser.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, AddUserActivity.class);
                startActivity(intent);
            }
        });
    }

}